# -*- coding: utf-8 -*-


def gen_AB():
    print("start")
    yield 'A'
    print('continue')
    yield 'B'
    print('end')

for c in gen_AB():
    print('---', c)



def my_gen():

    n = 1
    print('This is printed first, n= ', n)
    yield n

    n += 1
    print('This is printed second, n= ', n)
    yield n

    n += 1
    print('This is printed at last, n= ', n)
    yield n

a = my_gen()
i = next(a)
print(i)
i = next(a)
print(i)
i = next(a)
print(i)
